package pATT.bNEdit.gui;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;

import pATT.bNEdit.jgraph.org.jgraph.JGraph;
import pATT.bNEdit.jgraph.org.jgraph.graph.AttributeMap;
import pATT.bNEdit.jgraph.org.jgraph.graph.CellMapper;
import pATT.bNEdit.jgraph.org.jgraph.graph.CellViewRenderer;
import pATT.bNEdit.jgraph.org.jgraph.graph.GraphConstants;
import pATT.bNEdit.jgraph.org.jgraph.graph.VertexRenderer;
import pATT.bNEdit.jgraph.org.jgraph.graph.VertexView;


/**
 * <p>Title: BNEdit</p>
 * <p>Description: Monitor Vertex View representation </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author Luciana Zavaleta
 * @version 1.0
 */

public class MonitorVertexView extends VertexView {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	ViewRenderer renderer= new ViewRenderer();

	public MonitorVertexView(JGraph graph, CellMapper cm, Object cell){
		super(cell);
		
		//TODO cambiado CHAZO super(cell, graph, cm);

	}

	public Point getPerimeterPoint (Point source, Point p){
		return new Point ((p.x -source.x)/2, (p.y - source. x)/2);
	}

	public CellViewRenderer getRenderer(){
		return renderer;
	}

	class ViewRenderer extends VertexRenderer{
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		public void paint (Graphics g){
//			Map map = new Hashtable();
			Dimension size =((MonitorGraphCell) cell).getViewNodo().getDimension() 
			;
			AttributeMap attributes = ((MonitorGraphCell) cell).getAttributes();
			int x = (int) GraphConstants.getBounds(attributes).getX();
			int y = (int) GraphConstants.getBounds(attributes).getY();
			Point position = new Point(x, y);

			GraphConstants.setBounds(attributes, new Rectangle(position, size));

			((MonitorGraphCell) cell).getViewNodo().paint(g);

		}
	}

}
